package com.tiancheng.trade.settlement.service.settlement.impl;

import com.jcraft.jsch.ChannelSftp;
import com.tiancheng.trade.settlement.configuration.MidasSftpConfig;
import com.tiancheng.trade.settlement.service.settlement.IClearingFileService;
import com.tiancheng.trade.settlement.util.SftpUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 清分文件
 */
@Service
public class ClearingFileService implements IClearingFileService {

    @Resource
    SftpUtil sftpUtil;

    @Resource
    MidasSftpConfig midasSftpConfig;

    /**
     * 下载清分文件
     *
     * @return
     */
    @Override
    public void downloadClearingFile(String fileName) {
        ChannelSftp ftp = sftpUtil.getChannelSftp();
        if (null != ftp) {
            String saveFile = midasSftpConfig.getClearingDownloadPath() + fileName;
            sftpUtil.download(midasSftpConfig.getClearingDirectory(), fileName, saveFile, ftp);
        }
    }

}
